package course;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;

import notification.Notifiable;
import people.professor.Professor;

/**
 * 
 */

/**
 * @author Andreas Waldherr (e1028787@student.tuwien.ac.at)
 *
 */
public class Course extends AbstractCourse {
	
	private List<AbstractCourseType> types = new ArrayList<AbstractCourseType>();
	private boolean removed = false;

	/**
	 * 
	 * @param courseID
	 * @param courseName
	 * @param registerStart
	 * @param registerEnd
	 * @param unregisterEnd
	 */
	protected Course(String courseID, String courseName, Professor courseLeader, Date registerStart, Date registerEnd, Date unregisterEnd){
		super(courseID, courseName, courseLeader, registerStart, registerEnd, unregisterEnd);
	}
	
	/**
	 * 
	 * @return List of all types of this course
	 */
	public List<AbstractCourseType> getTypes() {
		return types;
	}

	/**
	 * 
	 * Sets the coursetypes-list
	 */
	protected void setTypes(List<AbstractCourseType> types) {
		this.types = types;
	}
	
	/**
	 * Adds an additional CourseType to the Course
	 */
	public void addTypes(AbstractCourseType type){
		if(types == null)
			types = new Vector<AbstractCourseType>();
		this.types.add(type);
	}
	
	/**
	 * is a course is removed, you can not (un-)register students from it.
	 * 
	 * @return if the course is in the state "removed"
	 */
	public boolean isRemoved() {
		return removed;
	}

	/**
	 * @param removed
	 */
	public void setRemoved(boolean removed) {
		this.removed = removed;
		if(this.removed){
			for(Notifiable n : this.getRegisteredStudents(getCourseLeader())) {
					n.notify("The course "+this.getCourseID()+"/"+this.getCourseName()+" has been removed!");
			}
		}
	}
	
	public String toString(){
		String ret = "";
		
		if(isRemoved())
			ret = "THIS COURSE IS REMOVED!  \n";
		
		ret += "LVA " + getCourseID() + ": " + getCourseName() + "\n" +
						"\tRegistration: " + getRegisterStart() + " - " + getRegisterEnd() + "\n" +
						"\tUn-register till: " + getUnregisterEnd() + "\n" + 
						getNumberOfRegistrations() + " already registered.";
		
		return ret;
	}
}
